package zwp.exercise.service.exercisedemo.chapterThree;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.UUID;

/**
 * @Author zwp14
 * @create 2025/10/22 22:57
 * @description 第三章最后的练习
 */
public class EndExerciseDemo {
    public static void main(String[] args) {
        // 象棋口诀
        exerciseDemoOne();
        // 输出汇款单
        exerciseDemoTwo();
        // 输出个人信息
        exerciseDemoThree();
        // 计算月收入
        exerciseDemoFour();
        // 计算商和余数
        exerciseDemoFive();
        // 判断成绩能否及格
        exerciseDemoSix();
        // 话费充值
        exerciseDemoSeven();
        // 货车装西瓜
        exerciseDemoEight();


    }

    /**
     * 车长400cm，宽160cm，高30cm，西瓜直径23cm
     * 车满载的时候能装多少个西瓜，实际能装多少个西瓜
     * 球形的体积，三分之四派啊的立方
     */
    private static void exerciseDemoEight() {
        System.out.println("第八道练习题");
        int carLong = 400;
        int carWide = 160;
        int carHigh = 30;
        int watermelonDiameter = 23;
        double a = 4/3;

        // 计算体积
        double watermelonVolume = a * watermelonDiameter * watermelonDiameter * watermelonDiameter;
        int carVolume = carLong * carWide * carHigh;

        // 计算该车子能够装下多少个西瓜
        double watermelonNum = carVolume / watermelonVolume;
        System.out.println("该车子能够装下西瓜数量为：" + watermelonNum);
        System.out.println("该车子能够装下西瓜数量实际为：" + (int)watermelonNum);
        System.out.println("####################################################################");
    }

    /**
     * 向手机中充值10元，通话0.2/分钟，流量0.3/mb。现在已经通话30分钟，流量使用10
     * 问，还剩多少分钟通话
     */
    private static void exerciseDemoSeven() {
        System.out.println("第七道练习题");
        int money = 10;
        int talk = 30;
        int traffic = 10;

        double a = 0.3;
        double b = 0.2;

        double trafficA = a * traffic;
        double talkB = b * talk;

        double remainingTalk = (money - trafficA - talkB) / b;
        System.out.println(remainingTalk);
        System.out.println("####################################################################");
    }


    /**
     * 学生八十分，≥60及格，三元运算符
     */
    private static void exerciseDemoSix() {
        System.out.println("第六道练习");
        int great = 80;
        String isPass = great >= 60 ? "成绩及格" : "成绩不及格";
        System.out.println(isPass);
        System.out.println("####################################################################");
    }

    /**
     * 数字123，输出321
     */
    private static void exerciseDemoFive() {
        System.out.println("第五道练习题");
        int num = 123;
        // 取余数得到3
        int a = num % 10;
        // 取余数得到2
        int b = num / 10 % 10;
        // 取余数得到1
        int c = num / 100 % 10;
        System.out.println(a + "" + b + "" + c);
        System.out.println("####################################################################");

    }

    /**
     * 每个月4500，奖金1000，缴纳社保500，求最终收入
     */
    private static void exerciseDemoFour() {
        System.out.println("第四道练习题");
        int moneySalary = 4500;
        int moneyBonus = 1000;
        int moneySocialInsurance = 500;
        int finalMoney = moneySalary + moneyBonus - moneySocialInsurance;
        System.out.println("小李的最终收入是：" + finalMoney);
        System.out.println("####################################################################");
    }

    /**
     * 控制台输出个人信息
     */
    private static void exerciseDemoThree() {
        System.out.println("第三道练习题");
        System.out.println("个人基本信息");
        System.out.println("姓名：李四");
        System.out.println("性别：男");
        System.out.println("年龄：25");
        System.out.println("身高：1.76米");
        System.out.println("体重：65.5千克");
        System.out.println("是否已婚：false");
        System.out.println("####################################################################");
    }

    /**
     * 输出汇款单
     */
    private static void exerciseDemoTwo() {
        System.out.println("第二道练习题");
        // 获取当前日期
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = simpleDateFormat.format(date);

        LocalDateTime now = LocalDateTime.now();
        String nowFormat = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));

        // 控制台输出
        System.out.println("----------------------");
        System.out.println("中国工商银行");
        System.out.println("日期：" + nowFormat);
        System.out.println("户名：" + "张三");
        System.out.println("账号：" + UUID.randomUUID().toString().replace("-",""));
        System.out.println("币种：" + "RMB");
        System.out.println("存款金额：" + "10000.0");
        System.out.println("存款序号:" + (int) (Math.random() * 10));
        System.out.println("柜员号：" + "12345");
        System.out.println("----------------------");

        System.out.println("####################################################################");
    }

    /**
     * 输出"马走日，象走田，小卒一去不复还"
     */
    private static void exerciseDemoOne() {
        System.out.println("第一道练习题");
        char a = '马';
        char b = '象';
        char c = '卒';

        System.out.println(a + "走日，" + b + "走田，" + "小" + c + "一去不复还");
        System.out.println("####################################################################");
    }
}
